//
//  OpinionTypeView.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/7/7.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//  请选择反馈类型

#import "OpinionTypeView.h"
#import "UIView+circular.h"
#import "MBProgressHUD+MJ.h"

@interface OpinionTypeView()
@property (weak, nonatomic) IBOutlet UIButton *saveBtn;

@property (nonatomic,strong) UIView*blckView;

@end

@implementation OpinionTypeView
+(instancetype)createView{
    
    OpinionTypeView *view = [[[NSBundle mainBundle]loadNibNamed:@"OpinionTypeView" owner:nil options:nil]lastObject];
    
    [view viewToCircular];
    [view.saveBtn viewToCircular];
    return view;
}
-(void)showInView:(UIView *)view
{
    self.blckView = [[UIView alloc]initWithFrame:view.bounds];
    [self.blckView setBackgroundColor:[UIColor blackColor]];
    self.blckView.alpha = 0.6;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGrayView)];
    [self.blckView addGestureRecognizer:tap];
    [view addSubview:self.blckView];
    
    CGFloat typeViewX = 15;
    CGFloat typeViewY = 100;
    CGFloat typeViewW = 290;
    CGFloat typeViewH = 230;
    self.frame = CGRectMake(typeViewX, typeViewY, typeViewW, typeViewH);
    [view addSubview:self];
    
}

-(void)tapGrayView{
    
    [self hide];
    
}

-(void)hide
{
    CGRect buf = self.frame;
    buf.origin.y += UIScreenHeight;
    [UIView animateWithDuration:0.2 animations:^{
        
        [self.blckView setAlpha:0];
        
        [self setFrame:buf];
        
    } completion:^(BOOL finished) {
        
        [self.blckView removeFromSuperview];
        [self removeFromSuperview];
    }];

}
- (IBAction)btnOnClick:(UIButton *)sender {
    
    if (sender.tag == 0) {
        [self hide];
        return;
    }
    if (self.delegate && [self.delegate respondsToSelector:@selector(OpinionTypeViewBtnOnClicked:)]) {
        
        [self.delegate OpinionTypeViewBtnOnClicked:sender];
    }


}

@end
